-
A navigation service coordinates various nonvisual components that track the user as they navigate along a predetermined route. You use
MapboxNavigationService
, which conforms to this protocol, either as part ofNavigationViewController
or by itself as part of a custom user interface. A navigation service calls methods on itsdelegate
, which conforms to theNavigationServiceDelegate
protocol, whenever significant events or decision points occur along the route.A navigation service controls a
NavigationLocationManager
for determining the user’s location, aRouter
that tracks the user’s progress along the route, aDirections
service for calculating new routes (only used when rerouting), and aNavigationEventsManager
for sending telemetry events related to navigation or user feedback.NavigationViewController
comes with aMapboxNavigationService
by default. You may override it to customize theDirections
service or simulation mode. After creating the navigation service, pass it intoNavigationOptions(styles:navigationService:voiceController:topBanner:bottomBanner:)
, then pass that object intoNavigationViewController(for:options:)
.If you use a navigation service by itself, outside of
See moreNavigationViewController
, callstart()
when the user is ready to begin navigating along the route.Declaration
Swift
@objc(MBNavigationService) public protocol NavigationService : CLLocationManagerDelegate, EventsManagerDataSource, RouterDataSource
-
A concrete implementation of the
NavigationService
protocol.NavigationViewController
comes with aMapboxNavigationService
by default. You may override it to customize theDirections
service or simulation mode. After creating the navigation service, pass it intoNavigationOptions(styles:navigationService:voiceController:topBanner:bottomBanner:)
, then pass that object intoNavigationViewController(for:options:)
.If you use a navigation service by itself, outside of
See moreNavigationViewController
, callstart()
when the user is ready to begin navigating along the route.Declaration
Swift
@objc(MBNavigationService) public class MapboxNavigationService : NSObject, NavigationService
extension MapboxNavigationService: CLLocationManagerDelegate
extension MapboxNavigationService: RouterDelegate
-
A
RouteController
tracks the user’s progress along a route, posting notifications as the user reaches significant points along the route. On every location update, the route controller evaluates the user’s location, determining whether the user remains on the route. If not, the route controller calculates a new route.
See moreRouteController
is responsible for the core navigation logic whereasNavigationViewController
is responsible for displaying a default drop-in navigation UI.Declaration
Swift
@objc(MBRouteController) open class RouteController : NSObject
extension RouteController: Router
-
See moreRouteProgress
stores the user’s progress along a route.Declaration
Swift
@objc(MBRouteProgress) open class RouteProgress : NSObject
-
See moreRouteLegProgress
stores the user’s progress along a route leg.Declaration
Swift
@objc(MBRouteLegProgress) open class RouteLegProgress : NSObject
extension RouteLegProgress: Encodable
-
See moreRouteStepProgress
stores the user’s progress along a route step.Declaration
Swift
@objc(MBRouteStepProgress) open class RouteStepProgress : NSObject
-
Keys in the user info dictionaries of various notifications posted by instances of
RouteController
.Declaration
Swift
public typealias RouteControllerNotificationUserInfoKey = MBRouteControllerNotificationUserInfoKey